﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:mui="http://firstfloorsoftware.com/ModernUI"
    xmlns:converters="clr-namespace:EpiNEXT.Core.Converters;assembly=EpiNEXT.Core"
    xmlns:local="clr-namespace:EpiNEXT.WPF">

    <DrawingBrush x:Key="GridBrush" Viewport="0,0,10,10" ViewportUnits="Absolute" TileMode="Tile">
        <DrawingBrush.Drawing>
            <DrawingGroup>
                <GeometryDrawing Geometry="M0,0 L1,0 1,0.1, 0,0.1Z" Brush="#EEEEEE" />
                <GeometryDrawing Geometry="M0,0 L0,1 0.1,1, 0.1,0Z" Brush="#EEEEEE" />
            </DrawingGroup>
        </DrawingBrush.Drawing>
    </DrawingBrush>

    <DataTemplate x:Key="FormDesignerPagesItemTemplate">
        <Border>
            <local:FormDesignerCanvas Background="White" Height="1010" Width="810" x:Name="canvasMain" PageId="{Binding PageId}" >

            </local:FormDesignerCanvas>
        </Border>
    </DataTemplate>

    <Style TargetType="{x:Type local:FormDesignerPages}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:FormDesignerPages}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <ItemsPresenter x:Name="panelMain" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <VirtualizingStackPanel />
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="{x:Type ContentPresenter}">
                    <Setter Property="Height" Value="Auto"></Setter>
                    <Setter Property="Margin" Value="0,0,0,0"></Setter>
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemTemplate" Value="{StaticResource FormDesignerPagesItemTemplate}" />
    </Style>

    <Style TargetType="{x:Type local:FormDesignerCanvas}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:FormDesignerCanvas}">
                    <Border x:Name="borderMain"  Background="White" BorderThickness="1" BorderBrush="#D8D8D8" Margin="0, 0, 0, 8" >
                        <!--<ItemsPresenter DataContext="{Binding Fields}" />-->
                        <local:DragCanvas SnapsToDevicePixels="True" Height="940" Width="730" x:Name="canvasMain"
                                          Background="{StaticResource GridBrush}"
                                          />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="{x:Type local:ElementDesignBorder}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type local:ElementDesignBorder}">
                    <Border Margin="-2" x:Name="PART_Border"
                        Background="Transparent"
                            BorderBrush="Transparent"
                            BorderThickness="2"
                            Visibility="Visible"
                            >
                        <ContentPresenter />
                    </Border>
                    <ControlTemplate.Triggers>
                        <!--<MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsSelected" Value="True" />
                            </MultiTrigger.Conditions>
                        </MultiTrigger>-->
                        <Trigger Property="IsSelected" Value="True" >
                            <Trigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Duration="0:0:0.15"
                    Storyboard.TargetName="PART_Border"
                    Storyboard.TargetProperty="BorderBrush.Color" To="#6495ED" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard FillBehavior="Stop">
                                        <ColorAnimation Duration="0:0:0.3"
                    Storyboard.TargetName="PART_Border"
                    Storyboard.TargetProperty="BorderBrush.Color" To="Transparent" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </Trigger.ExitActions>

                            <!--<Setter TargetName="PART_Border" Property="BorderBrush" Value="#6495ED" />-->
                        </Trigger>
                        
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsMouseOver" Value="True" />
                                <Condition Property="IsSelected" Value="False" />
                            </MultiTrigger.Conditions>
                            <MultiTrigger.EnterActions>
                                <BeginStoryboard>
                                    <Storyboard>
                                        <ColorAnimation Duration="0:0:0.15"
                                                        Storyboard.TargetName="PART_Border"
                                                        Storyboard.TargetProperty="BorderBrush.Color" To="#6495ED" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.EnterActions>

                            <MultiTrigger.ExitActions>
                                <BeginStoryboard>
                                    <Storyboard FillBehavior="Stop">
                                        <ColorAnimation Duration="0:0:0.15"
                                                        Storyboard.TargetName="PART_Border"
                                                        Storyboard.TargetProperty="BorderBrush.Color" To="Transparent" />
                                    </Storyboard>
                                </BeginStoryboard>
                            </MultiTrigger.ExitActions>
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>